﻿@page "/scheduler/inline-editing"

@using Syncfusion.Blazor.Schedule
@inherits SampleBaseComponent;

<SampleDescription>
    <p>This demo shows the experience of adding a new appointment or editing the existing appointment through inline mode. Click on the cells to add an appointment with the subject alone and click on the appointment to edit the subject of the appointment.   </p>
</SampleDescription>
<ActionDescription>
    <p>The features enable user to add or edit the appointment through inline mode. Click on the cells or the existing appointments to enable inline mode. You can press the ENTER key on the selected cell or appointment.
    <p> The feature activates when you enable the <code>AllowInline</code> property. For adding an appointment, the appointment will be created based on the selected time and subject once you focused-out or press ENTER key. For editing an appointment, the appointment will be saved based on the modified subject. </p> </p>
</ActionDescription>

<div class="control-section">
    <div class="content-wrapper">
        <SfSchedule TValue="ScheduleData.ResourceData" Width="100%" Height="650px" AllowInline="true" @bind-SelectedDate="@CurrentDate" @bind-CurrentView="@CurrentView">
            <ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings>
            <ScheduleViews>
                <ScheduleView MaxEventsPerRow="2" Option="View.TimelineWeek"></ScheduleView>
                <ScheduleView MaxEventsPerRow="2" Option="View.TimelineMonth"></ScheduleView>
            </ScheduleViews>
            <ScheduleGroup Resources="@ResourceName"></ScheduleGroup>
            <ScheduleResources>
                <ScheduleResource TItem="ResourceData" TValue="int" DataSource="@TaskData" Field="TaskId" Title="Category" Name="Categories" TextField="Text" IdField="Id" ColorField="Color"></ScheduleResource>
            </ScheduleResources>
        </SfSchedule>
    </div>
</div>

@code{
    private DateTime CurrentDate = new DateTime(2020, 1, 8);
    private View CurrentView = View.TimelineWeek;
    public string[] ResourceName = { "Categories" };
    public List<ResourceData> TaskData { get; set; } = new List<ResourceData> {
        new ResourceData{ Text = "Nancy", Id= 1, Color = "#df5286" },
        new ResourceData{ Text = "Steven", Id= 2, Color = "#7fa900" },
        new ResourceData{ Text = "Robert", Id= 3, Color = "#ea7a57" },
        new ResourceData{ Text = "Smith", Id= 4, Color = "#5978ee" },
        new ResourceData{ Text = "Michael", Id= 5, Color = "#df5286" }
    };
    public List<ScheduleData.ResourceData> DataSource = new ScheduleData().GetResourceData();
    public class ResourceData
    {
        public int Id { get; set; }
        public string Text { get; set; }
        public string Color { get; set; }
    }
}